Skip to content

fix: Add publish verification and failure detection to prevent false positives#116

Merged
konard merged 4 commits intomainfrom
issue-115-6e59e3366a6e
Jan 11, 2026
Merged

fix: Add publish verification and failure detection to prevent false positives#116
konard merged 4 commits intomainfrom
issue-115-6e59e3366a6e

Conversation

@konard
Copy link
Contributor

@konard konard commented Jan 10, 2026

Summary

This PR fixes the issue where npm publish failures were incorrectly reported as successes. The root cause was that changeset publish exits with code 0 even when packages fail to publish, and the script only relied on exception handling for failure detection.

Changes:

  • Multi-layer failure detection in publish-to-npm.mjs:

    • Output pattern matching for known error messages (packages failed to publish, npm error code E, E404, E401, E403, Access token expired, ENEEDAUTH)
    • Exit code checking (when available)
    • Post-publish verification by querying npm registry
    • Retry logic now properly triggers on all failure types
  • Case study documentation in docs/case-studies/issue-115/:

    • Detailed timeline of the original failure
    • Root cause analysis with error chain diagram
    • References to upstream changesets issues (#1621, #1280)
  • Test script in experiments/test-failure-detection.mjs:

    • Validates failure detection patterns against real CI output

Root Cause

The original issue occurred because:

  1. changeset publish exits with code 0 even when packages fail to publish (known upstream issue)
  2. The command-stream library doesn't throw exceptions on non-zero exit codes
  3. The script only used try-catch for failure detection

How it's Fixed

The script now:

  1. Captures the output of changeset publish using .run({ capture: true })
  2. Scans output for failure patterns
  3. Checks exit code (for defense in depth)
  4. Verifies the package is actually on npm after publish (ultimate verification)
  5. Only reports success after verification passes

Test Plan

  • Lint passes (npm run lint)
  • Format check passes (npm run format:check)
  • Unit tests pass (bun test tests/json-standard-unit.test.js)
  • Failure detection test passes (node experiments/test-failure-detection.mjs)

Related Issues

Fixes #115


🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #115
@konard konard self-assigned this Jan 10, 2026
…positives

The publish-to-npm.mjs script was falsely reporting success when changeset
publish failed. This happened because:
1. changeset publish exits with code 0 even when packages fail to publish
2. command-stream library doesn't throw exceptions on non-zero exit codes
3. The script only relied on exception handling to detect failures

This fix adds multi-layer failure detection:
- Output pattern matching for known error messages (E404, 401, 403, etc.)
- Exit code checking (when available)
- Post-publish verification by querying npm registry
- Retry logic now properly triggers on all failure types

Also adds comprehensive case study documentation in docs/case-studies/issue-115/
with timeline, root cause analysis, and references to upstream changesets issues.

Fixes #115

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@konard konard changed the title [WIP] Error was treated as success fix: Add publish verification and failure detection to prevent false positives Jan 11, 2026
konard and others added 2 commits January 11, 2026 01:01
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@konard konard marked this pull request as ready for review January 11, 2026 00:03
@konard
Copy link
Contributor Author

konard commented Jan 11, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $5.719787 USD
  • Calculated by Anthropic: $4.076503 USD
  • Difference: $-1.643284 (-28.73%)
    📎 Log file uploaded as GitHub Gist (666KB)
    🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard konard merged commit 0f49f75 into main Jan 11, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error was treated as success

1 participant